﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AvalonDock;

namespace HMS.Report
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class ReportManager : Window
    {
        public ReportManager()
        {
            InitializeComponent();
           
        }
        const string LayoutFileName = "SampleLayout.xml";

        private void SaveLayout(object sender, RoutedEventArgs e)
        {
            ReportDockingManager.SaveLayout(LayoutFileName);
        }
        private void CreateDocumentContent(string ReportName, UserControl ReportUserControl)
        {
    
            try
            {
                var documentContent = new DocumentContent();
                int documentCount = ReportDockPane.Items.Count == 0 ? 1 : ReportDockPane.Items.Count+1;
                documentContent.Title = ReportName+" ("+documentCount.ToString()+") ";            
                documentContent.Content = ReportUserControl;
                ReportDockPane.SelectedIndex = ReportDockPane.Items.Add(documentContent);
            }
            catch (Exception)
            {
                throw;
            }
        }

        private void TreeViewSubItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            TreeViewItem Item = ReportsTreeView.SelectedItem as TreeViewItem;
            switch (Item.Name)
            {
                    //Channeling
                case "DoctorPaySheetTreeViewSubItem":
                    CreateDocumentContent(Item.HeaderStringFormat, new ReportUserControls.DoctorPaySheetUserControl());
                    break;
                case "DoctorPaySheetSummaryTreeViewSubItem":
                    CreateDocumentContent(Item.HeaderStringFormat, new ReportUserControls.DoctorPaySheetSummaryUserControl());
                    break;

                    //Scan
                case "ScanSummaryByDoctorTreeViewSubItem":
                    CreateDocumentContent(Item.HeaderStringFormat, new ReportUserControls.ScanSummaryByDoctorUserControl());
                    break;

                    //X-Ray
                case "XRayDetailTreeViewSubItem":
                    CreateDocumentContent(Item.HeaderStringFormat, new ReportUserControls.XRayDetailUserControl());
                    break;

                     //Lab Test
                case "LabTestDetailTreeViewSubItem":
                    CreateDocumentContent(Item.HeaderStringFormat, new ReportUserControls.LabTestDetailUserControl());
                    break;

            }
        }
        
    }
}
